<template>
  <div class="page-container">
    <!-- 导航栏包裹在 sticky 容器中 -->
    <div class="nav-wrapper">
      <nav class="nav-menu">
        <a href="#" class="nav-item">首页</a>
        <a href="#" class="nav-item">关于我们</a>
        <a href="#" class="nav-item">服务</a>
        <a href="#" class="nav-item nav-item-last">联系我们</a>
      </nav>
    </div>

    <!-- 页面内容区域 -->
    <div class="content">
      <h2>欢迎来到我们的网站</h2>
      <p v-for="i in 50" :key="i">这是一段示例文本内容，用于演示滚动效果。</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'NavMenu'
}
</script>

<style scoped>
html,
body {
  padding: 0;
  margin: 0;
}

.page-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.nav-wrapper {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: white;
}

.nav-menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #ffffff;
  border-bottom: 1px solid #ddd;
  max-width: 800px;
  margin: 0 auto;
}

.nav-item {
  text-decoration: none;
  color: #333;
  font-size: 16px;
  padding: 8px 16px;
  transition: all 0.3s ease;
  position: relative;
}

.nav-item:hover {
  color: #007BFF;
  transform: scale(1.05);
}

.nav-item-last {
  margin-left: auto;
}

.content {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
  margin-top: 24px;
}
</style>